home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / ccas01.arc / INTC.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-03-15  |  2.9 KB  |  111 lines

  1. ;This subroutine will provide a standard interface to Lattice C (at least)
  2. ; to the interrupts provided.  All interrupts using register (not segment)
  3. ; elements are provided for, but the program may be easily modified.  The
  4. ; routine dynamically inserts the interupt code in the executable code.  All
  5. ; communications done with the module are through external integers (again
  6. ; easy to modify if you desire to change this).
  7. ;
  8. ; To call from C the protocol is: = 0 = 0
  9. ;
  10. ;    extern int intrpt();
  11. ;    extern int intrp,r_ax,r_bx,r_cx,r_dx;
  12. ;
  13. ;    /* assign r_ax,    r_bx, r_cx, r_dx to the register values */
  14. ;    /* assign intrp to the interupt number */
  15. ;    intrpt();
  16. ;
  17. ; See the example in TSTC.C to see it in use.  Please note that the routine
  18. ; works under DOS 1.1 with version 1.04, and under DOS 2.0 with the new C.OBJ
  19. ; generated from the C.ASM module stored under this BBS.
  20. ;
  21. ;                B. K. Jenkins
  22. ;
  23. ;
  24. ;
  25. DGROUP        GROUP    DATA
  26. DATA        SEGMENT    WORD PUBLIC 'DATA'
  27.         
  28.         assume    ds:dgroup
  29.  
  30.  
  31.     ;definition of data exchange area for subroutine
  32.     ; (NB communicate via c's char variables that contain
  33.     ; correct values for interrupt number to be processed, and
  34.     ; for the register set (ax,bx,cx,dx)
  35.  
  36.         public    intrp
  37.         public    r_ax
  38.         public    r_bx
  39.         public    r_cx
  40.         public    r_dx
  41.  
  42. intrp        dw    ?            ;interrupt number
  43. r_ax        dw    ?            ;value of ax for interrupt
  44. r_bx        dw    ?            ;value of bx for interrupt
  45. r_cx        dw    ?            ;value of cx for interrupt
  46. r_dx        dw    ?            ;value of dx for interrupt
  47.  
  48. DATA        ends
  49.  
  50. PGROUP        GROUP    PROG
  51.  
  52. PROG        SEGMENT    BYTE PUBLIC 'PROG'
  53.  
  54.         assume cs:pgroup
  55.  
  56.         public  INTRPT
  57.  
  58. ;*****************************
  59.  
  60. INTRPT        proc    near
  61.  
  62.         push    bp        ;save passed registers on stack
  63.         push    ax        ; (NB. some are not really needed)
  64.         push    bx
  65.         push    cx
  66.         push    dx
  67.  
  68.     ;insert interupt command at INT_NO in code
  69.         mov    dx,intrp    ;put interrupt number in dh code below
  70.         mov    dh,dl        ; (lsb contains number discard msb)
  71.         mov    dl,0cdh        ;code for INT (cdh) put in dl
  72.         push    ds        ;change ds to cs
  73.         push    cs
  74.         pop    ds
  75.         mov    [int_no],dx    ;put in interrupt command
  76.         pop    ds        ;restore ds
  77.  
  78.         mov    ax,r_ax        ;move desired register values to
  79.         mov    bx,r_bx        ;appropriate registers
  80.         mov    cx,r_cx
  81.         mov    dx,r_dx
  82.  
  83. INT_NO:        nop            ;these two bytes are replaced with
  84.         nop            ;the interrupt command desired
  85.                     ; (necessary because cannot use INT
  86.                     ; with a variable parameter)
  87.  
  88.         mov    dgroup:r_ax,ax    ;move register values produced by
  89.         mov    dgroup:r_bx,bx    ;interrupt back to register variables
  90.         mov    dgroup:r_cx,cx    ;that C can use
  91.         mov    dgroup:r_dx,dx
  92.  
  93.         pop    dx        ;recover saved registers
  94.         pop    cx
  95.         pop    bx
  96.         pop    ax
  97.         pop    bp
  98.  
  99.         ret
  100.  
  101. INTRPT        endp
  102.  
  103. PROG        ends
  104.  
  105.         end
  106.  
  107. 
  108.  
  109.         end
  110.  
  111.